﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AmiDraw.Editor.Factory
{
    public static class ResFactory
    {

        public static bool ImportImageToProject(string imgPath,string packName,bool deleteExist=false)
        {
            var imgName = Path.GetFileName(imgPath);
            var toPath = Path.Combine(Directory.GetCurrentDirectory(), "projects", packName, "datas", "image", imgName);
            FileFactory.InitDir( Path.GetDirectoryName(toPath));
            if (File.Exists(toPath) && !deleteExist)
            {
                return false;
            }
            else
            {
                File.Copy(imgPath, toPath, true);
                return true;
            }
        }
    }
}
